<!DOCTYPE html>
<html lang="en">
	<head>
		<title>three.js webgl - materials</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
		<style>
			body {
				color: #fff;
				font-family:Monospace;
				font-size:13px;
				text-align:center;

				background-color: #000;
				margin: 0px;
				overflow: hidden;
			}

			#info {
				position: absolute;
				top: 0px; width: 100%;
				padding: 5px;
			}
			#container{
			width: 600px;
			height: 500px;
			
			color: #fff;
				top: 10px;
				text-align: center;
				z-index: 100;
				background-color:#afd;
				display:block;
/* 				float:left; */
/* 				border-right: 1px red solid; */
			}
		</style>
	</head>
	<body>

		<div id="container"></div>
		<script src="three.js"></script>
		<script src="js/controls/OrbitControls.js"></script>
		<script src="js/effects/OutlineEffect.js"></script>
			<script src="js/renderers/Projector.js"></script>
		<script src="js/renderers/CanvasRenderer.js"></script>
		<script src="js/libs/dat.gui.min.js"></script>
		<script src="js/controls/TrackballControls.js"></script>
		<script src="me/jquery.min.js"></script>

		<script>
			var container;
			var camera, scene, renderer, controls, effect;
			var dom = $("#container");
			var width = dom.width();
			var height = dom.height();
// 			var width = window.innerWidth;
// 			var height = window.innerHeight;
			
			init(dom);
			animate();
			function init( dom ) {
				container = dom[0];
				camera = new THREE.PerspectiveCamera( 40, width/height, 1, 20000 );
				camera.position.set( 0.0, 400, 400 * 3.5 );
				var urls = ["5.jpg",	"3.jpg",	"6.jpg",	"4.jpg",	"2.jpg","1.jpg"];
				var reflectionCube = new THREE.CubeTextureLoader()
					.setPath( 'img/' )
// 					.load( [ 'px.jpg', 'nx.jpg', 'py.jpg', 'ny.jpg', 'pz.jpg', 'nz.jpg' ] );
					.load( urls );
				reflectionCube.format = THREE.RGBFormat;
				scene = new THREE.Scene();
				scene.background = reflectionCube;
				scene.add( new THREE.AmbientLight( "#eeeeee") );//环境光源
	//===============================文字2====================================
				var loader = new THREE.FontLoader(); 
				 loader.load("fonts/gentilis_regular.typeface.json", function (res) {
					 var font = new THREE.TextBufferGeometry("equipment", {
						  font: res,
						  size: 20,
						  height: 5
					  }); 
					  font.computeBoundingBox(); // 运行以后设置font的boundingBox属性对象，如果不运行无法获得。 
					  font.computeVertexNormals(); 
					  var material = new THREE.MeshLambertMaterial({side:THREE.DoubleSide,color: "#00ff00"}); 
					  fontModel = new THREE.Mesh(font,material); 
					  fontModel.position.set(350,2,3 );
					  scene.add(fontModel); 
				 }); 
	//===============================走线====================================
				var geometry_line = new THREE.Geometry();   //声明一个几何体
                var material_line = new THREE.LineBasicMaterial({ color: "#ffff00" ,linewidth: 10});   //定义材质外观
                var p1_line = new THREE.Vector3( 0, 0, 0 );
                var p2_line = new THREE.Vector3( 500, 0, 500 );
                geometry_line.vertices.push(p1_line); //vertices属性里可以存放点对象
                geometry_line.vertices.push(p2_line);
                var line = new THREE.Line(geometry_line, material_line, THREE.LinePieces);    //定义一条线
                scene.add(line);   //加入场景里
             //================================立方体贴图===================================
                var materials = [];
                for (var i = 1; i < 6; ++i) {
                    materials.push(new THREE.MeshBasicMaterial({
                        map: THREE.ImageUtils.loadTexture('img/' + i + '.jpg',
                            {}, function() {
                            	renderer.render( scene, camera );
//                             	effect.render( scene, camera );
                        }),
                    overdraw: true
                    }));
                }
                var cube = new THREE.Mesh(new THREE.CubeGeometry(200,200,100),new THREE.MeshFaceMaterial(materials));
                cube.aa = {name:"立方体"};
                cube.position.set( 100, 100, 50 );
                scene.add(cube);
              //===================================================================
   
          	  material = new THREE.MeshLambertMaterial( {
					color: 0x000360,
					side: 0
				} );
				object = new THREE.Mesh( new THREE.CylinderBufferGeometry( 4, 4, 40, 4, 0 ), material );
				object.position.set( -50, 20, 40 );
//				object.rotation.y = Math.PI / 4;
				scene.add( object );
				
				grid = new THREE.GridHelper( 200, 100, "#0000ff", "#ffa000" );
				
				//grid = new THREE.PolarGridHelper( 1, 1, 10, 100, "#0000ff", "#ffa000" );
				grid.rotateOnAxis( new THREE.Vector3( 0, 0, 0 ), 90 * ( Math.PI/180 ) );
				scene.add( grid );//设置网格
            	  
            	  
				renderer = new THREE.WebGLRenderer( { antialias: true } );
// 				renderer = new THREE.CanvasRenderer({ antialias: true });
				renderer.setPixelRatio( window.devicePixelRatio );
				renderer.setSize( width,height);
				container.appendChild( renderer.domElement );

				renderer.gammaInput = true;
				renderer.gammaOutput = true;
// 				effect = new THREE.OutlineEffect( renderer );//后面看不遮挡
				controls = new THREE.OrbitControls( camera );
				window.addEventListener( 'resize', onWindowResize, false );
			}
			function onWindowResize() {
				camera.aspect = width/height;
				camera.updateProjectionMatrix();
				renderer.setSize( width,height );
			}
			function animate() {
				requestAnimationFrame( animate );
				renderer.render( scene, camera );
// 				effect.render( scene, camera );
			}
		</script>

	</body>
</html>
